using System;
using System.Collections.Generic;
using System.Text;
using Pegasus.Threading;
using Pegasus.Diagnostics;

namespace Pegasus.UnitTests.Threading
{
    class TestTask : IScheduleTask
    {
        private const int MAX_COUNT = 5;
        private int count = 0;

        /// <summary>
        /// Gets the count.
        /// </summary>
        public int Count
        {
            get
            {
                return count;
            }
        }

        /// <summary>
        /// Gets the name of the task.
        /// </summary>
        public string Name
        {
            get
            {
                return "TestTask";
            }
        }

        /// <summary>
        /// Gets a value indicating whether this is a reoccurring task or not.
        /// </summary>
        public bool ReoccurringTask
        {
            get
            {
                count++;
                return count < MAX_COUNT;
            }
        }

        /// <summary>
        /// Gets the next date and time of the next occurrence of the task.
        /// </summary>
        public DateTime GetNextReoccurrence()
        {
            return DateTime.Now.AddSeconds( 5.0 );
        }

        public void RunTask()
        {
            Console.WriteLine( string.Format( "The task has run for the {0} time", count ) );
            //TraceCode.WriteLine( "The task has run for the {0} time", count );
        }
    }
}
